﻿package mortal.game.view.ThanksGiving.panel
{
    import com.gengine.core.frame.*;
    import com.mui.containers.globalVariable.*;
    import com.mui.controls.*;
    import com.mui.display.*;
    import extend.language.*;
    import fl.data.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.game.cache.*;
    import mortal.game.resource.*;
    import mortal.game.utils.*;
    import mortal.game.view.ThanksGiving.data.*;
    import mortal.game.view.ThanksGiving.item.*;
    import mortal.game.view.combinedServer.data.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;

    public class ThanksGivingConsumPanel extends GSprite
    {
        protected var _mbg:GImageBitmap;
        protected var _btmBg:ScaleBitmap;
        protected var _reNumDes:GTextFiled;
        protected var _reNum:GTextFiled;
        protected var _reBtn:GLoadingButton;
        protected var _list:GTileList;
        protected var _yuanbo:GBitmap;
        protected var _day:BitmapNumberText;
        protected var _hour:BitmapNumberText;
        protected var _min:BitmapNumberText;
        protected var _timeDes:GTextFiled;
        protected var _ruleDes:GTextFiled;
        protected var _sec:BitmapNumberText;
        private var _secT:SecTimer;

        public function ThanksGivingConsumPanel()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._mbg = UIFactory.gImageBitmap(ImagesConst.ThanksGivingComsumTopBg, 0, 0, this);
            this._btmBg = UIFactory.bg(-2, 180, 689, 374, this, ImagesConst.PanelBg);
            this._reNumDes = UIFactory.gTextField("", 350, 144, 100, 20, this, GlobalStyle.textFormatPutong.setColor(16777215).setSize(13));
            this._reNum = UIFactory.gTextField("12346", 417, 144, 100, 20, this, GlobalStyle.textFormatPutong.setColor(16777215).setSize(13));
            this._reBtn = UIFactory.gLoadingButton(ImagesConst.investmentRechargeBtn_upSkin, 540, 135, 141, 43, this);
            this._reBtn.label = "";
            this._list = UIFactory.tileList(0, 186, 685, 360, this);
            this._list.direction = GBoxDirection.VERTICAL;
            this._list.verticalGap = 0;
            this._list.horizontalGap = 2;
            this._list.rowHeight = 72;
            this._list.columnWidth = 670;
            this._list.columnCount = 1;
            this._list.rowCount = 5;
            this._list.width = 685;
            this._list.setStyle("cellRenderer", ThanksGivingComsumCell);
            this._yuanbo = UIFactory.gBitmap(ImagesConst.Yuanbao, 514, 145, this);
            this._day = UIFactory.bitmapNumberText(152, 98, "investmentNum.png", 24, 30, -8, this, 9, 1);
            this._day.text = "00";
            this._hour = UIFactory.bitmapNumberText(207, 98, "investmentNum.png", 24, 30, -8, this, 9, 1);
            this._hour.text = "00";
            this._min = UIFactory.bitmapNumberText(277, 98, "investmentNum.png", 24, 30, -8, this, 9, 1);
            this._min.text = "00";
            this._timeDes = UIFactory.gTextField("", 10, 137, 345, 20, this, GlobalStyle.textFormatPutong.setColor(16777215));
            this._ruleDes = UIFactory.gTextField("", 10, 158, 345, 20, this, GlobalStyle.textFormatPutong.setColor(16777215));
            this._sec = UIFactory.bitmapNumberText(350, 98, "investmentNum.png", 24, 30, -8, this, 9, 1);
            this._sec.text = "00";
            this._reNumDes.text = "" + Language.getString(71406);
            this._ruleDes.text = Language.getString(71407);
            this.setTime();
            this.updateInfo();
            this._reBtn.configEventListener(MouseEvent.CLICK, this.onGoToRechargeHd);
            this._secT = new SecTimer(1);
            this._secT.addListener(TimerType.ENTERFRAME, this.timeCk);
            this._secT.start();
            this.timeCk(null);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._secT.stop();
            this._secT = null;
            this._mbg = null;
            this._btmBg = null;
            this._reNumDes = null;
            this._reNum = null;
            this._reBtn = null;
            this._list = null;
            this._yuanbo = null;
            this._day = null;
            this._hour = null;
            this._min = null;
            this._timeDes = null;
            this._ruleDes = null;
            this._sec = null;
            super.disposeImpl(param1);
            return;
        }// end function

        public function updateInfo() : void
        {
            if (Cache.instance.thanksGiving == null || Cache.instance.thanksGiving.consumInfo == null)
            {
                return;
            }
            this._reNum.text = "" + Cache.instance.thanksGiving.consumInfo.recharge;
            var _loc_1:* = CombinedSerConfig.instance().getArrByGroup(ThanksGivingUtil.consumGroupId);
            var _loc_2:* = new DataProvider(_loc_1);
            this._list.dataProvider = _loc_2;
            this.scrollToCanGet();
            return;
        }// end function

        private function genArr(param1:Array) : Array
        {
            var _loc_4:Object = null;
            var _loc_2:Array = [];
            var _loc_3:int = 0;
            while (_loc_3 < param1.length)
            {
                
                _loc_4 = {};
                _loc_4.num = param1[_loc_3];
                _loc_2.push(_loc_4);
                _loc_3++;
            }
            return _loc_2;
        }// end function

        private function scrollToCanGet() : void
        {
            var _loc_1:* = ThanksGivingUtil.getRwIndex();
            if (_loc_1 != -1)
            {
                this._list.scrollToIndex(_loc_1);
            }
            this._list.drawNow();
            return;
        }// end function

        private function onGoToRechargeHd(event:MouseEvent) : void
        {
            GameUtil.gotoRecharge(ModuleTypeConst.ThanksGivingRecharge);
            return;
        }// end function

        private function setTime() : void
        {
            this._timeDes.text = ThanksGivingUtil.getOpenTimeStr(71375);
            return;
        }// end function

        private function timeCk(param1:SecTimer) : void
        {
            var _loc_2:Array = null;
            var _loc_3:int = 0;
            _loc_2 = ThanksGivingUtil.getDayCountDownTime();
            _loc_3 = _loc_2[5];
            this._day.text = "" + _loc_2[0];
            this._hour.text = "" + _loc_2[1];
            this._min.text = "" + _loc_2[2];
            this._sec.text = "" + _loc_2[3];
            if (_loc_3 > 0)
            {
                if (this._secT.running == false)
                {
                    this._secT.start();
                }
            }
            else
            {
                this._secT.stop();
            }
            return;
        }// end function

    }
}
